<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h2>Javascript能够验证输入</h2>
    <p>请输入1到100的数</p>
    
    <input id="num">
    <button onclick="myfunction()">提交</button>
    <p id="dm"></p>
    <script>
        var text,x;
        x = document.getElementById('num').Value;

         function myfunction(){
            if(x<1) {
            text = "yyjj";
            }
            else {
            text = "1212";
            }
            document.getElementById("dm").innerHTML = text;
            }(x)
        
    </script>
</body>
</html>